package main.chapter5.enums;/**
 * @Author xy
 * @Date 2020/6/16 17:12
 * @Description
 */

import java.util.Scanner;

/**
 * 文件名称： main.chapter5.enums.EnumTest.java</br>
 * 初始作者： xy</br>
 * 创建日期： 2020/6/16 17:12</br>
 * 功能说明： TODO <br/>
 * =================================================<br/>
 * 修改记录：<br/>
 * 修改作者        日期       修改内容<br/>
 * ================================================<br/>
 * Copyright (c) 2020-2021 .All rights reserved.<br/>
 */
public class EnumTest {
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        System.out.println("Enter a size:(SMALL, MEDIUM, LARGE, EXTRA_LARGE)");
        String input = in.next().toUpperCase();
        Size size = Enum.valueOf(Size.class,input);
        System.out.println("size="+size);
        System.out.println("value="+size.getValue());
        System.out.println("abbreviation="+size.getAbbreviation());
        if (size==Size.EXTRA_LARGE){
            System.out.println("Good job--you paid attention to the _.");
        }
    }
     enum Size{
        SMALL(0,"S"),MEDIUM(1,"M"),LARGE(1,"L"),EXTRA_LARGE(3,"XL");

         Size(int i, String abbreviation) {
             this.abbreviation = abbreviation;
             this.value = i;
         }

         public String getAbbreviation() {
             return abbreviation;
         }

         public int getValue() {
             return value;
         }

         private String abbreviation;

         private int value;
     }
}
